package com.t.screenofftouch;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharedPreferencesUtility {

	private static String shared_name = "screen_off_shared";

	
	public static void GetEditSharedPreferences(Context context, String anotherPrefName, String key, String value){
		SharedPreferences sharedPreferences =context.getSharedPreferences(anotherPrefName,0);
		Editor editor = sharedPreferences.edit();
		editor.putString(key, value);
		editor.commit();
	}
	
	public static String getStringPreferences(String key, String defaultValue, Context context) {
		SharedPreferences sharedPreferences =context.getSharedPreferences(shared_name,0);		
		String name = sharedPreferences.getString(key, defaultValue);
		return name;
	}

	public static int getIntPreferences(String key, int defaultValue, Context context) {
		SharedPreferences sharedPreferences =context.getSharedPreferences(shared_name,0);		
		int name = sharedPreferences.getInt(key, defaultValue);
		return name;
	}
	
	public static boolean getBooleanPreferences(String key, boolean defaultValue, Context context) {
		SharedPreferences sharedPreferences =context.getSharedPreferences(shared_name,0);		
		boolean name = sharedPreferences.getBoolean(key, defaultValue);
		return name;
	}
	
	public static void savePreferences(String key, boolean value,Context context) {
		SharedPreferences sharedPreferences =context.getSharedPreferences(shared_name,0);
		Editor editor = sharedPreferences.edit();
		editor.putBoolean(key, value);
		editor.commit();
	}

	public static void savePreferences(String key, String value, Context context) {
		SharedPreferences sharedPreferences =context.getSharedPreferences(shared_name,0);
		Editor editor = sharedPreferences.edit();
		editor.putString(key, value);
		editor.commit();
	}
	
	public static void savePreferences(String key, int value, Context context) {
		SharedPreferences sharedPreferences =context.getSharedPreferences(shared_name,0);
		Editor editor = sharedPreferences.edit();
		editor.putInt(key, value);
		editor.commit();
	}
	
	@SuppressLint("InlinedApi")
	public static void saveAnotherPreferences(String key, String value, Context context, String shared_name) {
		SharedPreferences sharedPreferences =context.getSharedPreferences(shared_name,1|2| Context.MODE_MULTI_PROCESS);
		Editor editor = sharedPreferences.edit();
		editor.putString(key, value);
		editor.commit();
	}
	
	@SuppressLint("InlinedApi")
	public static String getStringAnotherPreferences(String key, String defaultValue, Context context,String shared_name) {
		SharedPreferences sharedPreferences =context.getSharedPreferences(shared_name,1|2| Context.MODE_MULTI_PROCESS);		
		String name = sharedPreferences.getString(key, defaultValue);
		return name;
	}
}